import Operator from "./Operator";
import { RC } from "../config/RC";
import MessageBox from "../entities/MessageBox";
import { SYSTEM, GROUP } from "../config/config";
import MessageBoxForGroup from "../entities/MessageBoxForGroup";

class CreateGroupMessageBoxOperator extends Operator {
    public async execute(): Promise<RC> {
        let groupId: string = this.args.getProperty("generateId");
        if (groupId === '' || groupId === null || groupId === undefined) {
            console.log(4);
            return RC.INVALID_ARGUMENT;
        }
        const messageBox = new MessageBoxForGroup(GROUP, groupId); // 创建一个信箱对象
        messageBox.insertNewMessage(SYSTEM, groupId, "信箱初始化","我",groupId);  // 插入数据库

        this.args.setProperty("MessageObj", messageBox);
        return RC.SUCCESS;
    }
}

export default CreateGroupMessageBoxOperator;